import unittest
from selenium import webdriver
from Page.loginPage import loginPage
from publicModule.login import login
from Page.menu import menu
from Page.inputInsurance import inputInsurance
import time

class newBusiness(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get("http://10.22.26.34:8080/fwd/indexlis.jsp")
        time.sleep(3)
        self.loginPage = loginPage(self.driver)
        self.login =login(self.driver)
        self.menu = menu(self.driver)
        self.inputInsurance =inputInsurance(self.driver)
    def tearDown(self):
        self.driver.quit()
    #登录
    def test01(self):
        self.username = 'fw001'
        self.password = '001'
        self.orgcode = '862101'
        login.login(self,self.username,self.password,self.orgcode)
        time.sleep(2)
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("head")
        self.menu.groupLife().click()
        time.sleep(1)
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraMenu")
        self.menu.newOrder().click()
        time.sleep(1)
        self.menu.inputInsurance().click()
        time.sleep(2)
        #################查询及进入投保人信息录入页面#######################
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(1)
        self.inputInsurance.inputNumber().send_keys("GA4420181106888")
        self.inputInsurance.check().click()
        time.sleep(2)
        self.inputInsurance.publicLake().click()
        time.sleep(1)
        self.inputInsurance.apply().click()
        time.sleep(2)
        windows = self.driver.window_handles
        self.driver.switch_to.window(windows[-1])
        self.driver.find_element_by_id("butSubmit").click()
        time.sleep(3)
        windows1 = self.driver.window_handles
        self.driver.switch_to.window(windows1[-1])
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame("fraInterface")
        time.sleep(2)
        self.inputInsurance.personLake().click()
        time.sleep(2)
        self.inputInsurance.getInto().click()


if __name__ =='__main__':
    suite = unittest.TestLoader.loadTestsFromTestCase(newBusiness)
    unittest.TextTestRunner().run(suite)
